package com.chainyoung.component_tmperson.ui.mvp.presenter;

import com.chainyoung.common.appcommon.entity.HdWalletCache;
import com.chainyoung.common.base.CommonSubscriber;
import com.chainyoung.common.mvp.BasePresenter;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.ui.mvp.contract.HdWalletSettingContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.ImportWalletContract;

import java.util.List;

import javax.inject.Inject;

public class HdWalletSettingPresenter extends BasePresenter<HdWalletSettingContract.Model, HdWalletSettingContract.View> {


    @Inject
    public HdWalletSettingPresenter(HdWalletSettingContract.Model model, HdWalletSettingContract.View rootView) {
        super(model, rootView);
    }




    public void addHdWalletCache(HdWalletCache item) {
        addSubscribe(mModel.addHdWalletCache(item)
                .compose(RxUtils.<HdWalletCache>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<HdWalletCache>(mView,true) {
                    @Override
                    public void onNext(HdWalletCache data) {
                        mView.onAddHdWalletCacheSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));
    }

    public void getAllHdWalletCaches(String coinType) {
        addSubscribe(mModel.getAllHdWalletCaches(coinType)
                .compose(RxUtils.<List<HdWalletCache>>rxSchedulerHelper())
                .subscribeWith(new CommonSubscriber<List<HdWalletCache>>(mView) {
                    @Override
                    public void onNext(List<HdWalletCache> data) {
                        mView.onGetAllHdWalletCaches(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                }));


    }



}




